<?php

/*
 * 中间件
 */
//处理带有斜线结尾的 URL 和不带斜线的 URL 的方式不同
$app -> add('App\Middlewares\TrailingSlashMiddleware');
/*
 * 用户登陆
 */
$app -> get('/login', 'App\Controllers\UserController:Login') -> setname('Login');
$app -> post('/login', 'App\Controllers\UserController:postLogin');
$app -> get('/logout', 'App\Controllers\UserController:Logout') -> setname('Logout');
$app -> get('/405', 'App\Controllers\UserController:Error') -> setname('Error');
$app -> get('/404', 'App\Controllers\UserController:Error404') -> setname('Error404');
$app -> get('/', 'App\Controllers\UserController:Login');
$app -> get('/menu', 'App\Controllers\UserController:Menu');
$app -> get('/role/info', 'App\Controllers\RoleController:RoleInfo');
$app->get('/user/pas', 'App\Controllers\UserController:Pas');
$app->get('/user/cha', 'App\Controllers\UserController:Cha');
$app->post('/user/xgimg', 'App\Controllers\UserController:xgimg');
$app->get('/user/img', 'App\Controllers\UserController:Img');
$app->post('/user/img', 'App\Controllers\UserController:HeadImg');
$app -> get('/power/info', 'App\Controllers\PowerController:PowerInfo');
$app->get('/user/chaid', 'App\Controllers\UserController:Chaid');

$app -> group('', function() {
	$this -> post('/user/add', 'App\Controllers\UserController:UserAdd');
	$this -> get('/user/update', 'App\Controllers\UserController:UserUpdate');
	$this -> post('/user/update', 'App\Controllers\UserController:RoleUserUpdate');
	$this -> get('/user/delete', 'App\Controllers\UserController:UserDelete');
	$this -> get('/user/select', 'App\Controllers\UserController:UserNameSelect');
	$this -> get('/user/info', 'App\Controllers\UserController:UserInfo')->setname('UserInfo');
	$this -> get('/user/item', 'App\Controllers\UserController:UserItem');
	$this -> get('/user/password', 'App\Controllers\UserController:UserPas');
	$this -> get('/user/look', 'App\Controllers\UserController:UserLook');
	$this -> get('/user/list', 'App\Controllers\UserController:UserList');
	
	$this -> get('/role/add', 'App\Controllers\RoleController:RoleAdd');
	$this -> get('/role/delete', 'App\Controllers\RoleController:RoleDelete');
	$this -> get('/role/update', 'App\Controllers\RoleController:RoleUpdate');
	$this -> get('/role/list', 'App\Controllers\RoleController:RoleList');
	$this -> get('/role/item', 'App\Controllers\RoleController:RoleItem');
	
//	$this -> get('/power/add', 'App\Controllers\PowerController:PowerAdd');
//	$this -> get('/power/delete', 'App\Controllers\PowerController:PowerDelete');
//	$this -> get('/power/update', 'App\Controllers\PowerController:PowerUpdate');
	$this -> get('/power/list', 'App\Controllers\PowerController:PowerList');
//	$this -> get('/power/item', 'App\Controllers\PowerController:PowerItem');
}) -> add(new App\Middlewares\RoleMiddleware($container)) -> add(new App\Middlewares\AuthMiddleware($container));
